class Solution {
    public String replaceSpace(String s) {
        StringBuilder str = new StringBuilder(s);
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == ' ') {
                str.append("%20");
            } else {
                str.append(ch);
            }
        }
        return str.toString();
    }
}